//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS Pricing service.
///
/// The Amazon Web Services Price List API is a centralized and convenient way to programmatically query Amazon Web Services for services, products, and pricing information. The Amazon Web Services Price List uses standardized product attributes such as Location, Storage Class, and Operating System, and provides prices at the SKU level. You can use the Amazon Web Services Price List to do the following:   Build cost control and scenario planning tools   Reconcile billing data   Forecast future spend for budgeting purposes   Provide cost benefit analysis that compare your internal workloads with Amazon Web Services   Use GetServices without a service code to retrieve the service codes for all Amazon Web Services services, then GetServices with a service code to retrieve the attribute names for that service. After you have the service code and attribute names, you can use GetAttributeValues to see what values are available for an attribute. With the service code and an attribute name and value, you can use GetProducts to find specific products that you're interested in, such as an AmazonEC2 instance, with a Provisioned IOPS volumeType. For more information, see Using the Amazon Web Services Price List API in the Billing User Guide.
public struct Pricing: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the Pricing client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "AWSPriceListService",
            serviceName: "Pricing",
            serviceIdentifier: "api.pricing",
            signingName: "pricing",
            serviceProtocol: .json(version: "1.1"),
            apiVersion: "2017-10-15",
            endpoint: endpoint,
            errorType: PricingErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Returns the metadata for one service or a list of the metadata for all services. Use this without a service code to get the service codes for all services. Use it with a service code, such as AmazonEC2, to get information specific to  that service, such as the attribute  names available for that service. For example, some of the attribute names available for EC2 are  volumeType, maxIopsVolume, operation, locationType, and instanceCapacity10xlarge.
    @Sendable
    @inlinable
    public func describeServices(_ input: DescribeServicesRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DescribeServicesResponse {
        try await self.client.execute(
            operation: "DescribeServices", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns the metadata for one service or a list of the metadata for all services. Use this without a service code to get the service codes for all services. Use it with a service code, such as AmazonEC2, to get information specific to  that service, such as the attribute  names available for that service. For example, some of the attribute names available for EC2 are  volumeType, maxIopsVolume, operation, locationType, and instanceCapacity10xlarge.
    ///
    /// Parameters:
    ///   - formatVersion: The format version that you want the response to be in. Valid values are: aws_v1
    ///   - maxResults: The maximum number of results that you want returned in the response.
    ///   - nextToken: The pagination token that indicates the next set of results that you want to retrieve.
    ///   - serviceCode: The code for the service whose information you want to retrieve, such as AmazonEC2. You can use  the ServiceCode to filter the results in a GetProducts call. To retrieve a list of all services, leave this blank.
    ///   - logger: Logger use during operation
    @inlinable
    public func describeServices(
        formatVersion: String? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        serviceCode: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DescribeServicesResponse {
        let input = DescribeServicesRequest(
            formatVersion: formatVersion, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            serviceCode: serviceCode
        )
        return try await self.describeServices(input, logger: logger)
    }

    /// Returns a list of attribute values. Attributes are similar to the details  in a Price List API offer file. For a list of available attributes, see  Offer File Definitions in the Billing and Cost Management User Guide.
    @Sendable
    @inlinable
    public func getAttributeValues(_ input: GetAttributeValuesRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetAttributeValuesResponse {
        try await self.client.execute(
            operation: "GetAttributeValues", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a list of attribute values. Attributes are similar to the details  in a Price List API offer file. For a list of available attributes, see  Offer File Definitions in the Billing and Cost Management User Guide.
    ///
    /// Parameters:
    ///   - attributeName: The name of the attribute that you want to retrieve the values for, such as volumeType.
    ///   - maxResults: The maximum number of results to return in response.
    ///   - nextToken: The pagination token that indicates the next set of results that you want to retrieve.
    ///   - serviceCode: The service code for the service whose attributes you want to retrieve. For example, if you want  the retrieve an EC2 attribute, use AmazonEC2.
    ///   - logger: Logger use during operation
    @inlinable
    public func getAttributeValues(
        attributeName: String,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        serviceCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetAttributeValuesResponse {
        let input = GetAttributeValuesRequest(
            attributeName: attributeName, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            serviceCode: serviceCode
        )
        return try await self.getAttributeValues(input, logger: logger)
    }

    ///   This feature is in preview release and is subject to change. Your use of Amazon Web Services Price List API is subject to the Beta Service Participation terms of the Amazon Web Services Service Terms (Section 1.10).   This returns the URL that you can retrieve your Price List file from. This URL is based on the PriceListArn and FileFormat that you retrieve from the ListPriceLists response.
    @Sendable
    @inlinable
    public func getPriceListFileUrl(_ input: GetPriceListFileUrlRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetPriceListFileUrlResponse {
        try await self.client.execute(
            operation: "GetPriceListFileUrl", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///   This feature is in preview release and is subject to change. Your use of Amazon Web Services Price List API is subject to the Beta Service Participation terms of the Amazon Web Services Service Terms (Section 1.10).   This returns the URL that you can retrieve your Price List file from. This URL is based on the PriceListArn and FileFormat that you retrieve from the ListPriceLists response.
    ///
    /// Parameters:
    ///   - fileFormat: The format that you want to retrieve your Price List files in. The FileFormat can be obtained from the ListPriceLists response.
    ///   - priceListArn: The unique identifier that maps to where your Price List files are located. PriceListArn can be obtained from the ListPriceLists response.
    ///   - logger: Logger use during operation
    @inlinable
    public func getPriceListFileUrl(
        fileFormat: String,
        priceListArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetPriceListFileUrlResponse {
        let input = GetPriceListFileUrlRequest(
            fileFormat: fileFormat, 
            priceListArn: priceListArn
        )
        return try await self.getPriceListFileUrl(input, logger: logger)
    }

    /// Returns a list of all products that match the filter criteria.
    @Sendable
    @inlinable
    public func getProducts(_ input: GetProductsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetProductsResponse {
        try await self.client.execute(
            operation: "GetProducts", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a list of all products that match the filter criteria.
    ///
    /// Parameters:
    ///   - filters: The list of filters that limit the returned products. only products that match all filters are returned.
    ///   - formatVersion: The format version that you want the response to be in. Valid values are: aws_v1
    ///   - maxResults: The maximum number of results to return in the response.
    ///   - nextToken: The pagination token that indicates the next set of results that you want to retrieve.
    ///   - serviceCode: The code for the service whose products you want to retrieve.
    ///   - logger: Logger use during operation
    @inlinable
    public func getProducts(
        filters: [Filter]? = nil,
        formatVersion: String? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        serviceCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetProductsResponse {
        let input = GetProductsRequest(
            filters: filters, 
            formatVersion: formatVersion, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            serviceCode: serviceCode
        )
        return try await self.getProducts(input, logger: logger)
    }

    ///   This feature is in preview release and is subject to change. Your use of Amazon Web Services Price List API is subject to the Beta Service Participation terms of the Amazon Web Services Service Terms (Section 1.10).   This returns a list of Price List references that the requester if authorized to view, given a ServiceCode, CurrencyCode, and an EffectiveDate. Use without a RegionCode filter to list Price List references from all available Amazon Web Services Regions. Use with a RegionCode filter to get the Price List reference that's specific to a specific Amazon Web Services Region. You can use the PriceListArn from the response to get your preferred Price List files through the GetPriceListFileUrl API.
    @Sendable
    @inlinable
    public func listPriceLists(_ input: ListPriceListsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListPriceListsResponse {
        try await self.client.execute(
            operation: "ListPriceLists", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///   This feature is in preview release and is subject to change. Your use of Amazon Web Services Price List API is subject to the Beta Service Participation terms of the Amazon Web Services Service Terms (Section 1.10).   This returns a list of Price List references that the requester if authorized to view, given a ServiceCode, CurrencyCode, and an EffectiveDate. Use without a RegionCode filter to list Price List references from all available Amazon Web Services Regions. Use with a RegionCode filter to get the Price List reference that's specific to a specific Amazon Web Services Region. You can use the PriceListArn from the response to get your preferred Price List files through the GetPriceListFileUrl API.
    ///
    /// Parameters:
    ///   - currencyCode: The three alphabetical character ISO-4217 currency code that the Price List files are denominated in.
    ///   - effectiveDate: The date that the Price List file prices are effective from.
    ///   - maxResults: The maximum number of results to return in the response.
    ///   - nextToken: The pagination token that indicates the next set of results that you want to retrieve.
    ///   - regionCode: This is used to filter the Price List by Amazon Web Services Region. For example, to get the price list only for the US East (N. Virginia) Region, use us-east-1. If nothing is specified, you retrieve price lists for all applicable Regions. The available RegionCode list can be retrieved from GetAttributeValues API.
    ///   - serviceCode: The service code or the Savings Plan service code for the attributes that you want to retrieve. For example, to get the list of applicable Amazon EC2 price lists, use AmazonEC2. For a full list of service codes containing On-Demand and Reserved Instance (RI) pricing, use the DescribeServices API. To retrieve the Reserved Instance and Compute Savings Plan price lists, use ComputeSavingsPlans.  To retrieve Machine Learning Savings Plans price lists, use MachineLearningSavingsPlans.
    ///   - logger: Logger use during operation
    @inlinable
    public func listPriceLists(
        currencyCode: String,
        effectiveDate: Date,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        regionCode: String? = nil,
        serviceCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListPriceListsResponse {
        let input = ListPriceListsRequest(
            currencyCode: currencyCode, 
            effectiveDate: effectiveDate, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            regionCode: regionCode, 
            serviceCode: serviceCode
        )
        return try await self.listPriceLists(input, logger: logger)
    }
}

extension Pricing {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: Pricing, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Pricing {
    /// Return PaginatorSequence for operation ``describeServices(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func describeServicesPaginator(
        _ input: DescribeServicesRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<DescribeServicesRequest, DescribeServicesResponse> {
        return .init(
            input: input,
            command: self.describeServices,
            inputKey: \DescribeServicesRequest.nextToken,
            outputKey: \DescribeServicesResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``describeServices(_:logger:)``.
    ///
    /// - Parameters:
    ///   - formatVersion: The format version that you want the response to be in. Valid values are: aws_v1
    ///   - maxResults: The maximum number of results that you want returned in the response.
    ///   - serviceCode: The code for the service whose information you want to retrieve, such as AmazonEC2. You can use  the ServiceCode to filter the results in a GetProducts call. To retrieve a list of all services, leave this blank.
    ///   - logger: Logger used for logging
    @inlinable
    public func describeServicesPaginator(
        formatVersion: String? = nil,
        maxResults: Int? = nil,
        serviceCode: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<DescribeServicesRequest, DescribeServicesResponse> {
        let input = DescribeServicesRequest(
            formatVersion: formatVersion, 
            maxResults: maxResults, 
            serviceCode: serviceCode
        )
        return self.describeServicesPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``getAttributeValues(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func getAttributeValuesPaginator(
        _ input: GetAttributeValuesRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<GetAttributeValuesRequest, GetAttributeValuesResponse> {
        return .init(
            input: input,
            command: self.getAttributeValues,
            inputKey: \GetAttributeValuesRequest.nextToken,
            outputKey: \GetAttributeValuesResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``getAttributeValues(_:logger:)``.
    ///
    /// - Parameters:
    ///   - attributeName: The name of the attribute that you want to retrieve the values for, such as volumeType.
    ///   - maxResults: The maximum number of results to return in response.
    ///   - serviceCode: The service code for the service whose attributes you want to retrieve. For example, if you want  the retrieve an EC2 attribute, use AmazonEC2.
    ///   - logger: Logger used for logging
    @inlinable
    public func getAttributeValuesPaginator(
        attributeName: String,
        maxResults: Int? = nil,
        serviceCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<GetAttributeValuesRequest, GetAttributeValuesResponse> {
        let input = GetAttributeValuesRequest(
            attributeName: attributeName, 
            maxResults: maxResults, 
            serviceCode: serviceCode
        )
        return self.getAttributeValuesPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``getProducts(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func getProductsPaginator(
        _ input: GetProductsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<GetProductsRequest, GetProductsResponse> {
        return .init(
            input: input,
            command: self.getProducts,
            inputKey: \GetProductsRequest.nextToken,
            outputKey: \GetProductsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``getProducts(_:logger:)``.
    ///
    /// - Parameters:
    ///   - filters: The list of filters that limit the returned products. only products that match all filters are returned.
    ///   - formatVersion: The format version that you want the response to be in. Valid values are: aws_v1
    ///   - maxResults: The maximum number of results to return in the response.
    ///   - serviceCode: The code for the service whose products you want to retrieve.
    ///   - logger: Logger used for logging
    @inlinable
    public func getProductsPaginator(
        filters: [Filter]? = nil,
        formatVersion: String? = nil,
        maxResults: Int? = nil,
        serviceCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<GetProductsRequest, GetProductsResponse> {
        let input = GetProductsRequest(
            filters: filters, 
            formatVersion: formatVersion, 
            maxResults: maxResults, 
            serviceCode: serviceCode
        )
        return self.getProductsPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listPriceLists(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listPriceListsPaginator(
        _ input: ListPriceListsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListPriceListsRequest, ListPriceListsResponse> {
        return .init(
            input: input,
            command: self.listPriceLists,
            inputKey: \ListPriceListsRequest.nextToken,
            outputKey: \ListPriceListsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listPriceLists(_:logger:)``.
    ///
    /// - Parameters:
    ///   - currencyCode: The three alphabetical character ISO-4217 currency code that the Price List files are denominated in.
    ///   - effectiveDate: The date that the Price List file prices are effective from.
    ///   - maxResults: The maximum number of results to return in the response.
    ///   - regionCode: This is used to filter the Price List by Amazon Web Services Region. For example, to get the price list only for the US East (N. Virginia) Region, use us-east-1. If nothing is specified, you retrieve price lists for all applicable Regions. The available RegionCode list can be retrieved from GetAttributeValues API.
    ///   - serviceCode: The service code or the Savings Plan service code for the attributes that you want to retrieve. For example, to get the list of applicable Amazon EC2 price lists, use AmazonEC2. For a full list of service codes containing On-Demand and Reserved Instance (RI) pricing, use the DescribeServices API. To retrieve the Reserved Instance and Compute Savings Plan price lists, use ComputeSavingsPlans.  To retrieve Machine Learning Savings Plans price lists, use MachineLearningSavingsPlans.
    ///   - logger: Logger used for logging
    @inlinable
    public func listPriceListsPaginator(
        currencyCode: String,
        effectiveDate: Date,
        maxResults: Int? = nil,
        regionCode: String? = nil,
        serviceCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListPriceListsRequest, ListPriceListsResponse> {
        let input = ListPriceListsRequest(
            currencyCode: currencyCode, 
            effectiveDate: effectiveDate, 
            maxResults: maxResults, 
            regionCode: regionCode, 
            serviceCode: serviceCode
        )
        return self.listPriceListsPaginator(input, logger: logger)
    }
}

extension Pricing.DescribeServicesRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> Pricing.DescribeServicesRequest {
        return .init(
            formatVersion: self.formatVersion,
            maxResults: self.maxResults,
            nextToken: token,
            serviceCode: self.serviceCode
        )
    }
}

extension Pricing.GetAttributeValuesRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> Pricing.GetAttributeValuesRequest {
        return .init(
            attributeName: self.attributeName,
            maxResults: self.maxResults,
            nextToken: token,
            serviceCode: self.serviceCode
        )
    }
}

extension Pricing.GetProductsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> Pricing.GetProductsRequest {
        return .init(
            filters: self.filters,
            formatVersion: self.formatVersion,
            maxResults: self.maxResults,
            nextToken: token,
            serviceCode: self.serviceCode
        )
    }
}

extension Pricing.ListPriceListsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> Pricing.ListPriceListsRequest {
        return .init(
            currencyCode: self.currencyCode,
            effectiveDate: self.effectiveDate,
            maxResults: self.maxResults,
            nextToken: token,
            regionCode: self.regionCode,
            serviceCode: self.serviceCode
        )
    }
}
